package thread1;

public class Demo4 {

    public static boolean isQuit = true;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
           while(isQuit){
               System.out.println("线程进行");
               try {
                   Thread.sleep(1000);
               } catch (InterruptedException e) {
                   throw new RuntimeException(e);
               }
           }
            System.out.println("线程结束");
        });

        System.out.println("标志位为 true");
        thread.start();
        Thread.sleep(4000);
        isQuit = false;
        System.out.println("标志位为 false");
    }
}
